package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.OrderDTO;
import com.itheima.pojo.OrderInfoVO;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userOrderController")
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 用户端-新增预约
     */
    @PostMapping("/submitOrder")
    public Result submitOrder(@RequestBody OrderDTO orderDTO){
        log.info("新增预约:{}", orderDTO);
        return orderService.submitOrder(orderDTO);
    }

    /**
     * 根据id查询预约
     */
    @PostMapping("/findById")
    public Result findById(Integer id){
        OrderInfoVO orderInfoVO = orderService.findById(id);
        return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS, orderInfoVO);
    }
}
